package arrayInit;

import org.antlr.v4.runtime.CharStream;
import org.antlr.v4.runtime.CharStreams;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.tree.ParseTree;
import org.antlr.v4.runtime.tree.ParseTreeWalker;

import java.io.IOException;

public class Translate {
    public static void main(String[] args) throws IOException {
        System.out.println("please input tokens to test, using ctrl+d or ctrl+z to end input");
        //输入
        CharStream input = CharStreams.fromStream(System.in);

        //词法分析
        ArrayInitLexer lexer = new ArrayInitLexer(input);

        CommonTokenStream tokenStream = new CommonTokenStream(lexer);

        ArrayInitParser parser = new ArrayInitParser(tokenStream);
        //begin parsing at init value
        ParseTree tree = parser.init();

        ParseTreeWalker walker = new ParseTreeWalker();
        walker.walk(new ShortToUnicodeString(), tree);
        System.out.println();
    }
}
